package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 添加一个新的菜品
     *
     * @param
     */
    @AutoFill(value = OperationType.INSERT)
    void add(Dish dish);

    /**
     * 菜品分页查询
     *
     * @param dto
     * @return
     */
    Page<DishVO> listByPage(DishPageQueryDTO dto);


    /**
     * 根据id获得对象
     *
     * @param id
     * @return
     */
    @Select("select * from dish where id=#{id}")
    Dish getById(Long id);

    /**
     * 根据id删除菜品
     *
     * @param id
     */
    @Delete("delete from dish where id=#{id}")
    void deleteById(Long id);

    /**
     * 更新对象
     *
     * @param dishUpdate
     */
    void update(Dish dishUpdate);

    /**
     * 通过名字选择菜单
     *
     * @param name
     * @return
     */
    @Select("select * from dish where name=#{name}")
    Dish selectByName(String name);

    /**
     * 改变状态
     *
     * @param dish
     */
    @Select("select * from dish where id=#{id}")
    void changeStatus(Dish dish);

    /**
     * 通过分类id查询菜品
     *
     * @param id
     * @return
     */
    List<Dish> listByCategoryId(Long id);

    /**
     * 通过分类的id去查询菜品名字
     *
     * @param id
     * @return
     */
    @Select("select name from dish where dish.category_id=#{id}")
    List<String> listNameByCategorysId(Long id);

    List<Dish> list(Dish dish);
}
